const path=require('path');
const app=require('express')();

app.get('/',(req,res)=>{
    let html='<ul>';
    html+=[1,2].map(n=>`<li><a href="/download/${n}.txt">${n}.txt</a></li>`).join('\n');
    html+='</ul>';
    res.type('html').end(html);
});

app.get('/download/:file(*)(*)(*)',(req,res)=>{
    let file=req.params.file;
    console.log('params:',req.params);
    console.log('file:',file);
    res.download(path.join(__dirname,file));
});
app.listen(4000,()=>{
    console.log('Download @port 4000',new Date());
});